package com.liyunc.demo.resources;
/**
 * Copyright (c) 2018-2022 ThunderSoft
 * All Rights Reserved by Thunder Software Technology Co., Ltd and its affiliates.
 * You may not use, copy, distribute, modify, transmit in any form this file
 * except in compliance with ThunderSoft in writing by applicable law.
 */

import com.liyunc.demo.model.dto.GenericDto;
import com.liyunc.demo.model.entity.PermissionInfo;
import com.liyunc.demo.service.PermissionService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;
import java.util.Set;

/**
 * @author
 * @version 1.0
 * @file
 * @brief
 * @details
 * @date 2022-02-25
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2022-02-25                       Created
 */
@RestController
@RequestMapping(value = "/api/v1/permission", produces = {MediaType.APPLICATION_JSON_VALUE})
public class PermissionResource {

    @Autowired
    private PermissionService permissionService;

    @GetMapping(value = "/{userId}")
    @Operation(description = "获取单个用户")
    public GenericDto<Set<PermissionInfo>> getSingleUserByUserId(
        @Min(value = 1) @PathVariable("userId") long userId) {
        return GenericDto.of(permissionService.findAllByCurrent().orElse(null));
    }
}
